package com.dimples.dd.gateway.route.handler;

import com.dimples.dd.gateway.route.DynamicRouteLoader;
import com.dimples.dd.redis.core.constant.RedisConstants;
import com.dimples.dd.redis.core.listener.RedisListener;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 路由刷新监听（实现方式：redis监听handler）
 *
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/9/13
 */
@Slf4j
@Component(RedisConstants.LOADER_ROUTER_HANDLER)
public class LoaderRouterHandler implements RedisListener {

    @Resource
    private DynamicRouteLoader dynamicRouteLoader;
    
    @Override
    public void onMessage(Map<String, Object> message) {
        dynamicRouteLoader.refresh(message);
    }

}